<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/26 0026
 * Time: 10:22
 */
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Request;
use app\admin\model\AuthAccess;

class Admin extends Controller{
    /* define();*/
    protected $ruleMode;
    public function _initialize()
    {
        //初始化常量
        $this->initDefine();
        if(!is_login()){
            echo '请登录';
        }
        //判断权限
        $uid = session('uid');
        $url = MODULE.'/'.CONTROLLER.'/'.ACTION;
        $this->ruleModel = new AuthAccess();
        $res = $this->ruleModel->checkRule($uid,$url);
        if(!$res){
            exit("无权访问");
        }
        parent::_initialize();
    }
    public function index(){
        return $this->fetch();
    }
    public function initDefine()
    {

        define('IS_ROOT',1);
        define('MODULE',strtolower($this->request->module()));
        define('CONTROLLER',strtolower($this->request->controller()));
        define('ACTION',strtolower($this->request->action()));
        define('SYS_DS_PROS'    , '/');
    }

}